Numerically controlled machine tool and a program transforming method therefor

ABSTRACT

The present invention provides a numerically controlled machine tool and a program transforming method therefor where a NC program is transformed into an optimum program even by a non-expert programmer. Particularly, the present invention provides a method for optimizing a NC program for operating a numerically controlled machine tool, comprising: making the NC program to be loaded into the numerically controlled machine tool; designating a portion of the NC program to be determined whether it is transformable and/or a portion of the NC program to be determined whether a command position is changeable; storing the NC program in a memory; determining whether the designated portion is transformable and/or whether the designated command position is changeable; and transforming the designated portion and/or changing the designated command position, and making an operating program file for the numerically controlled machine tool.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a numerically controlled machine tooland a program transforming method therefor, particularly to those inwhich a NC program is transformed into optimum conditions so that theintended operation may be smoothly performed with accuracy

2. Description of the Related Art

A NC (numerical control) program for operating a workpiece or a tool isprepared in advance and then loaded into the machine tool to manufacturea product.

Initially, since the programming is manually done, the finished programtotally depends on the capability or experience of the operator.

Recently, as shown in JP-A-7-168612, an automatic programming isavailable by a CAD system or separate programming support system. Theoperator inputs CAD drawings and machining conditions such as the typeof material and the feed rate into the system. NC programming is thenavailable regardless of the capability or experience of the operator.

The conventional programming method or the conventional NC machine tool,however, does not fully satisfy an increasing demand from the market for“large item small scale production”.

The program achieves a certain level but it is standardized orundifferentiated. It is not so optimized as the expert programmer doesso that it does not fully respond to changing conditions. It likelycause a problem including machining time extension, product costincrease, machining accuracy deterioration, and machine life shortening.

SUMMARY OF THE INVENTION

An object of the present invention is to provide a numericallycontrolled machine tool and a program transforming method therefor wherea NC program is transformed into an optimum program even by a non-expertprogrammer.

The present invention provides a method for optimizing a NC program foroperating a numerically controlled machine tool, comprising: making theNC program to be loaded into the numerically controlled machine tool;designating a portion of the NC program to be determined whether it istransformable and/or a portion of the NC program to be determinedwhether a command position is changeable; storing the NC program in amemory; determining whether the designated portion is transformableand/or whether the designated command position is changeable; andtransforming the designated portion and/or changing the designatedcommand position, and making an operating program file for thenumerically controlled machine tool.

Particularly, the present invention provides a method for optimizing aNC program for operating a numerically controlled machine tool,comprising: making the NC program to be loaded into the numericallycontrolled machine tool; designating an operation of a workpiece or atool in the NC program to be transformed into electronic cam data inmaking the NC program; storing the NC program in a memory; searching thedesignated operation in the NC program stored in the memory anddetermining whether it is transformable into electronic cam data;transforming the designated operation into electronic cam data byhypothetically operating the workpiece and the tool as described in theNC program; making a table for storing the electronic cam data; andreplacing the transformed portion of the NC program by a commandreferring to the table.

Further, the present invention provides a method for optimizing a NCprogram for operating a numerically controlled machine tool, comprising:making the NC program to be loaded into the numerically controlledmachine tool; designating a portion of the NC program to be determinedwhether a tool selection command position is changeable; storing the NCprogram in a predetermined memory; determining whether the operatingtime by the selected tool is shortened by changing the command position;and changing the command position and making an operating program filefor the numerically controlled machine tool.

Further, the present invention provides a numerically controlled machinetool, comprising: a NC program to be loaded into the numericallycontrolled machine tool; designating means for designating a portion ofthe NC program to be determined whether it is transformable and/or aportion of the NC program to be determined whether a command position ischangeable; memory means for storing the NC program containing thedesignation; determining means for determining whether the designatedportion is transformable and/or whether the designated command positionis changeable; and a numerical control unit for transforming thedesignated portion and/or changing the designated command position, andoperating the machine tool according to the result of the transformationand/or change.

Further, the present invention provides the numerically controlledmachine tool as claimed in claim 4 further comprises collecting meansfor collecting positional offset data of a workpiece or a tool and forapplying the offset data to the result of transformation in transformingthe designated portion of the NC program.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing the structure of the machine tool ofthe present invention.

FIG. 2 is a diagram showing the channel structure.

FIG. 3 is an electronic cam data table stored in the RAM of the controlunit.

FIG. 4 is a main flow chart of the control program of the presentinvention.

FIG. 5A is a subroutine of FIG. 4 showing transformation of asimultaneous operation program into electronic cam data FIG. 5B is anexample of a machining operation on a workpiece.

FIG. 5C is an expanded view of FIG. 5B.

FIG. 6 is a subroutine of FIG. 5A showing search procedure for a portionof the simultaneous operation program to be transformed.

FIG. 7 is a subroutine of FIG. 5A showing transformation of asimultaneous operation program into electronic cam data.

FIG. 8 is a subroutine of FIG. 4 showing transformation of anon-simultaneous operation program into electronic cam data.

FIG. 9 is a subroutine of FIG. 8 showing search procedure for a portionof the non-simultaneous operation program to be transformed.

FIG. 10 is a subroutine of FIG. 8 showing transformation procedure ofthe non-simultaneous operation program.

FIG. 11A is a subroutine of FIG. 4 showing optimization procedure of atool selection command position.

FIG. 11B is an example of the optimization.

FIG. 11C is the result of the optimization of FIG. 11B.

FIG. 12 is a subroutine of FIG. 11A showing retrieval procedure of linesA B, and C, and tool selection command line T for Channels 1 and 3.

FIG. 13 is a subroutine of FIG. 11A showing optimization procedure oftool selection command position.

FIG. 14 is a subroutine of FIG. 4 showing transformation of toolselection operation program into electronic cam data.

FIG. 15 is a subroutine of FIG. 14 showing retrieval procedure of linesA, B, and C, and tool selection command line T.

FIG. 16 is a subroutine of FIG. 14 showing transformation of toolselection operation program into electronic cam data.

DETAILED DESCRIPTION OF THE INVENTION

The present invention will be described below in detail with referenceto the accompanying drawings.

FIG. 1 is a block diagram showing the structure of a numericallycontrolled machine tool 1 according to the present invention. Themachine tool 1 comprises a spindle rotating motor 11, a tool movingmotor 21, a workpiece moving motor 31, a sub-spindle unit moving motor41, a sub-spindle rotating motor 61, and a control unit 51 for drivingthe motors 11, 21, 31, 41, and 61.

The spindle rotating motor 11 is connected to the control unit 51 via adriving circuit 12 and a spindle rotation control circuit 13 to rotate aspindle (not shown) where the workpiece is held. The spindle rotatingmotor 11 is provided with a pulse encoder 14 for detecting a rotation ofthe spindle rotating motor 11. The output of the pulse encoder 14 isconnected to the control unit 51 and a speed signal generating circuit15. The pulse encoder 14 generates a rotation detection signal insynchronous with rotation of the spindle rotating motor 11 (spindle) totransmit it to the control unit 51 and the speed signal generatingcircuit 15. The speed signal generating circuit 15 converts the rotationdetection signal into a spindle rotational speed signal representing arotational speed of the spindle rotating motor 11 (spindle). The outputof the speed signal generating circuit 15 is connected to the spindlerotation control circuit 13 to which the converted signal is inputted.

The spindle rotation control circuit 13 controls the workpiece (spindle)to rotate at a desired rotational speed on the basis of a clock signalgenerated by a clock signal generating circuit 54 described later.Particularly, the spindle rotation control circuit 13 compares a spindlerotational speed command signal from the control unit 51 with thespindle rotational speed signal from the speed signal generating circuit15, thereby generating a control signal according to the differential onthe basis of the clock signal. The generated control signal is outputtedto the driving circuit 12.

The driving circuit 12, in response to the control signal from thespindle rotation control circuit 13, controls power supply to thespindle rotating motor 11 to change the rotational speed thereof to be aspindle rotational speed command value (described later). The drivingcircuit 12, the spindle rotation control circuit 13, and the speedsignal generating circuit 15 constitute a feedback control system forthe spindle rotating motor 11 (spindle) with respect to a rotationalspeed thereof.

The tool moving motor 21 moves a machining tool (cutting tool, etc.),for example, in a direction (X-axis direction, Y-axis direction)perpendicular to the rotational center axis of the spindle rotatingmotor 11 or in a direction (Z-axis direction) parallel to the spindle.The tool moving motor 21 is connected to the control unit 51 via adriving circuit 22 and a tool feed control circuit 23. The tool movingmotor 21 is provided with a pulse encoder 24 for detecting a rotation ofthe tool moving motor 21. The output of the pulse encoder 24 isconnected to the tool feed control circuit 23. The pulse encoder 24generates a rotational position signal every predetermined rotationalangle of the tool moving motor 21 to transmit it to the tool feedcontrol circuit 23.

The tool feed control circuit 23 recognizes an actual position of thetool in response to the rotational position signal, and compares theactual position of the tool with a tool position command signal from thecontrol unit 51 (described later), thereby generating a tool drivingsignal as a result of the comparison. The tool driving signal isoutputted to the driving circuit 22. The driving circuit 22 controlspower supply to the tool moving motor 21 in response to the tool drivingsignal. The driving circuit 22 and the tool feed control circuit 23constitute a feedback system for the tool with respect to the movingposition thereof.

The workpiece moving motor 31 moves the workpiece, for example, in adirection (Z-axis direction) parallel to the rotational center axis ofthe spindle rotating motor 11. The workpiece moving motor 31 isconnected to the control unit 51 via a driving circuit 32 and aworkpiece feed control circuit 33. The workpiece moving motor 31 isprovided with a pulse encoder 34 for detecting a rotation of theworkpiece moving motor 31. The output of the pulse encoder 34 isconnected to the workpiece feed control circuit 33. The pulse encoder 34generates a rotational position signal every predetermined rotationalangle of the workpiece moving motor 31 to transmit it to the workpiecefeed control circuit 33.

The workpiece feed control circuit 33 recognizes an actual position ofthe workpiece in response to the rotational position signal, andcompares the actual position of the workpiece with a workpiece positioncommand signal from the control unit 51, thereby generating a workpiecedriving signal as a result of the comparison. The workpiece drivingsignal is outputted to the driving circuit 32 every predeterminedrotational angle of the workpiece moving motor 31. The driving circuit32 controls power supply to the workpiece moving motor 31 in response tothe workpiece driving signal. The driving circuit 32 and the workpiecefeed control circuit 33 constitute a feedback system for the workpiecewith respect to the moving position thereof.

The sub-spindle unit moving motor 41 moves a sub-spindle, for example,in a direction (Z-axis direction) parallel to the rotational center axisof the spindle rotating motor 11 or in a direction (X-axis direction)perpendicular to the same. The sub-spindle unit moving motor 41 isconnected to the control unit 51 via a driving circuit 42 and asub-spindle unit feed control circuit 43. The sub-spindle unit movingmotor 41 is provided with a pulse encoder 44 for detecting a rotation ofthe sub-spindle unit moving motor 41. The output of the pulse encoder 44is connected to the sub-spindle unit feed control circuit 43. The pulseencoder 44 generates a rotational position signal every predeterminedrotational angle of the sub-spindle unit moving motor 41 to transmit itto the sub-spindle unit feed control circuit 43.

The sub-spindle unit feed control circuit 43 recognizes an actualposition of the sub-spindle unit in response to the rotational positionsignal, and compares the actual position of the sub-spindle unit with asub-spindle unit position command signal from the control unit 51(described later), thereby generating a sub-spindle unit driving signalas a result of the comparison. The sub-spindle unit driving signal isoutputted to the driving circuit 42. The driving circuit 42 controlspower supply to the sub-spindle unit moving motor 41 in response to thesub-spindle unit driving signal. The driving circuit 42 and thesub-spindle unit feed control circuit 43 constitute a feedback systemfor the sub-spindle unit with respect to the moving position thereof.

The sub-spindle rotating motor 61 rotates the sub-spindle for holdingthe workpiece. The sub-spindle rotating motor 61 is connected to thecontrol unit 51 via a driving circuit 62 and a sub-spindle rotationcontrol circuit 63. The sub-spindle rotating motor 61 is provided with apulse encoder 64 for detecting a rotation of the sub-spindle rotatingmotor 61. The output of the pulse encoder 64 is connected to the controlunit 51 and a speed signal generating circuit 65. The pulse encoder 64generates a rotational detection signal every predetermined rotationalangle of the sub-spindle rotating motor 61 to transmit it to the controlunit 51 and the speed signal generating circuit 65. The speed signalgenerating circuit 65 converts the rotation detection signal into asub-spindle rotational speed signal representing the rotational speed ofthe sub-spindle rotating motor 61 (sub-spindle). The output of the speedsignal generating circuit 65 is connected to the sub-spindle rotationcontrol circuit 63. The converted signal is inputted to the sub-spindlerotation control circuit 63.

The sub-spindle rotation control circuit 63 controls the sub-spindle(workpiece) to rotate at a desired speed based on a clock signalgenerated by a clock signal generating circuit described later.Particularly, the sub-spindle rotation control circuit 63 compares thesub-spindle rotational speed command signal from the control unit 51with the sub-spindle rotational speed signal from the speed signalgenerating circuit 65, thereby generating a control signal based on theclock signal. The generated control signal is outputted to the drivingcircuit 62.

The driving circuit 62 controls power supply to the sub-spindle rotatingmotor 61 to cause it to rotate at the sub-spindle rotational speedcommand value (described later). The driving circuit 62, the sub-spindlerotation control circuit 63, and the speed signal generating circuit 65constitute a feedback system for the sub-spindle with respect to therotational speed thereof.

The control unit 51 comprises, as shown in FIG. 1, a central processingunit (CPU) 52, pulse signal generating circuits 53 a and 53 b, the clocksignal generating circuit 54, a divided timing signal generating circuit55, a random access memory (RAM) for the NC device 56, a read onlymemory (ROM) 57, and a random access memory (RAM) for PC 58.

The CPU 52 controls an entire signal processing of the control unit 51.The CPU 52 performs a well-known multi-processing operation where aplurality of jobs (programs) is changed over at short intervals toenable an apparent simultaneous processing of a plurality of programs.Such multi-processing operation includes a time-divided operation or atask operation where jobs are executed in order of priority.

The pulse signal generating circuits 53 a and 53 b are respectivelyconnected to the pulse encoders 14 and 64 for receiving the rotationdetection signal therefrom via an interface, etc., and therebygenerating a pulse signal every predetermined rotational angle. Thepulse signal generating circuits 53 a and 53 b are also connected to theCPU 52 for transmission of the pulse signals thereto. In thisembodiment, the pulse signal generating circuits 53 a and 53 brespectively output 4,096 pulse signals at regular intervals insynchronous with the spindle rotating motor 11 and the sub-spindlerotating motor 61 everytime they make a single rotation.

The clock signal generating circuit 54 is adapted to generate a clocksignal at a predetermined interval, for example 0.25 millisecond, inresponse to a predetermined command signal from the CPU 52. Thegenerated clock signal is outputted to the divided timing signalgenerating circuit 55. The divided timing signal generating circuit 55counts the number of clock signals from the clock signal generatingcircuit 54, then generating a divided timing signal, for example, everyelapse of one (1) millisecond, and transmitting it to the CPU 52. Thus,the divided timing signal generating circuit 55 outputs a divided timingsignal as an interrupt timing signal to the CPU 52 at one (1)millisecond interval. The interval of the clock signal or the dividedtiming signal is not limited to the above example. It may be anyappropriate value according to the capability or performance of the CPU52, the pulse encoders 24, 34, and 44, and the motors 11, 21, 31, and41.

The RAM for the NC device 56 is adapted to temporarily and readablystore the results of various calculations by the CPU 52. It stores an NCprogram (machining program) and all the data required to execute the NCprogram, comprising a first channel machining sequence storage portion56 a, a second channel machining sequence storage portion 56 b, a thirdchannel machining sequence storage portion 56 c, and an electronic camdata table 56 d.

The electronic cam data table is provided for electronic cam control. Asshown in JP-A-2001-170843, ever-changing moving command data of a movingaxis is generated from ever-changing rotational position data of areference axis and a command position data of the moving axispredetermined for every unit rotational position of the reference axis.A command speed data of the moving axis, which is synchronous with therotational speed of the workpiece, is generated from the moving commanddata and the rotational position data. The tool position is controlledbased on the moving command data and the command speed data.

FIG. 2 shows the operation of the machine tool 1 based on the NC programstored in the first channel machining sequence storage portion 56 a(Channel 1), the second channel machining sequence storage portion 56 b(Channel 2), and the third channel machining sequence storage portion 56c (Channel 3). The NC program stored in Channel 1 controls the spindlerotating motor 11, the tool moving motor 21, and the workpiece movingmotor 31. The spindle S1 is thereby controlled in the Z1-axis directionand in the C1 rotational direction. A tool TS1 is controlled in theX1-axis or the Y1-axis direction. Rotational control of a rotary tool isalso executed, if any. The NC program stored in Channel 2 controls thesub-spindle rotating motor 61, the sub-spindle unit moving motor 41, anda tool TS2. The sub-spindle S2 is thereby controlled in the Z2-axis orX2-axis direction and in the C2 rotational direction. The tool TS2 maybe a non-rotary tool such as a bite or a rotary tool such as a drill.Rotational control of a rotary tool is also executed, if any. The NCprogram stored in Channel 3 controls the tool moving motor 21. A toolTS3 is thereby controlled in the X3-axis, Y3-axis or Z3-axis direction.Rotational control of a rotary tool is also executed, if any.

Channel allocation is optional. The tool TS1 may be controlled byChannel 3 or the tool TS3 may be controlled by Channel 1, for example.The same is true to the spindle S1 and the sub spindle S2.

The electronic cam data table 56 d in the RAM for the NC device 56stores, as shown in FIG. 3, a plurality of electronic cam data tableshaving identification numbers N respectively. Each electronic cam datatable comprises positional data (Z) of the workpiece and positional data(X) of the tool, which are respectively set every predeterminedaccumulated number of rotation (A) of the spindle rotating motor 11.Each electronic cam data table comprises an end code representing theend of machining. The predetermined accumulated number of rotation (A)may correspond to each predetermined rotational angle, though increasingthe storage capacity.

The ROM 57 stores various processing programs including a calculationprogram for determining the moving position of the workpiece or the toolevery predetermined time interval, for example every one (1)millisecond, in a screw-thread cutting operation. It further stores acalculation program for determining the moving position of theworkpiece, the tool, or the drilling tool every predetermined rotationalangle of the spindle rotating motor 11.

The CPU 52 counts the number of pulse signals generated by the pulsesignal generating circuit 53 according to the program stored in the ROM57, and, from the counted results, calculates the accumulated number ofrotations of the spindle rotating motor 11.

The RAM for PC 58 temporarily stores calculation results by the CPU 52.The RAM for PC 58 comprises a transformation program storage portion 58a and all the reference data required to effect the transformation. Partof the reference data is stored in an electronic cam data storage table58 b, a machine specific data storage portion 58 c, and a NC programstorage portion 58 d. A NC program is prepared in advance by use of, forexample, programming supports tool and then loaded into the machine orthe NC device thereof.

The transformation program storage portion 58 a stores a transformationprogram of the present invention. The electronic cam data storage table58 b stores an electronic cam data of the NC program after execution ofthe transformation program. The machine specific data storage portion 58c stores various reference data such as tool offset, command operationtime, and operating conditions. The NC program storage portion 58 dstores a NC program to be transformed into an optimum data program.

Operation of the machine tool or the NC device thereof is beingdescribed below referring to FIG. 4 showing the main routine.

In Step A, a timekeeping module is operated. The NC program stored inthe NC device is simulated. Waiting time and tool selection time ismeasured and entire operation time is calculated for each channel(Channel 1, 2, 3). Calculation is performed by referring to a data tableof the NC device which stores various data including motor acceleration,tool offset, and workpiece offset.

Particularly, the timekeeping module reads out from the NC program acoordinate value and feed rate of the tool and a rotational speed andmovement of the spindle. The retrieved coordinate value does not includetool offset or workpiece offset. Then, moving distance and moving speedat each coordinate value is calculated by referring to offset data inthe data table of the NC device. A moving locus of the tool is thusderived, and operation time is calculated by referring to motoracceleration data of each motor in the data table.

In Step A1, the time data calculated in Step A is read.

In Step B, the NC program is read into the NC program storage portion 58d. The original file is retained here to enable any modification to beapplied in subsequent steps.

In Step C, the NC program is searched for a simultaneous operationsequence to be transformed into electronic cam data, and the sequence,if any, is transformed into electronic cam data.

In Step D, a designated non-simultaneous sequence is transformed intoelectronic cam data. The operator may put a flag up to a portion whereelectronic cam data is better suitable for a particular purpose than theoriginal program. Such machining sequence includes a threading andtapping.

In Step E, a tool selection command position is optimized. Particularly,the position is shifted if the shift can save operation time.

In Step F, the tool selection operation is optimized. Particularly, thetool of one channel is controlled to be slowly selected (moved) by useof electronic cam data if time allows in view of the tool of the otherchannels. It reduces load on a ball screw and a bearing of the toolpost, preventing adverse influence on the machine life and machiningaccuracy.

In Step G, an operating program file is made. Data stored in the NCprogram storage portion 58 d and the electronic cam data storage table58 b are loaded into the first, the second, and the third channelmachining sequence storage portions 56 a, 56 b, 56 c respectively, andsuch data are also sent to the electronic cam data table. The Step Goperation is triggered by a transformer button 59 provided on anoperation panel of the control unit 51.

The Steps C to G are being described in detail to fully describe thepresent invention.

1.1 Explanation of Step C in FIG. 4

FIG. 5A is a subroutine of FIG. 4 showing transformation of asimultaneous operation program into electronic cam data.

In summary, the NC program is examined to find a simultaneous operationsequence that should be transformed into electronic cam data, and thetransformation is done if any. Electronic cam data could possiblyeliminate a problem as seen in the original NC program, such as a cuttermark due to out of synchronization of the channels. It could alsopossibly achieve an operation that is not fulfilled by the original NCprogram.

In Step 1, a line number B is reset to “0” and a channel CH is reset to“1”.

In Step 2, the NC program, particularly the simultaneous operationsequence is searched for a portion where electronic cam data is bettersuitable for a particular purpose than the original NC program.

In Step 3, it is determined whether there exists a portion to betransformed. If such portion is found, the process goes to Step 4.

In Step 4, transformation start line number A and transformation endline number B are retrieved.

In Step 5, from the NC program between the lines A and B, the movinglocus of the control axis is transformed into electronic cam data. Whenthe transformation is completed, the same processing is repeated for theNC program subsequent to the line B.

On the other hand, if a transformable portion is not found in Step 3,the process returns to the main routine (Step D) in FIG. 4.

The Steps 2 and 5 in FIG. 5 is described later for more detail.

The above-described transformation would shorten the machining time andimproves the product quality in such operation as shown in FIG. 5B.Particularly, there is no cutter mark left in the product. Inmanufacturing a stepped rod 71 with a groove 75, a simultaneousoperation may be performed by sequential use of a plurality of tools inorder. For example, just when a tool 74 reaches a stepped portion 72, atool 73 is started to machine the groove 75.

The NC program, however, ordinarily inserts “waiting” for suchoperation. The tool 74 “waits” at the stepped portion 72 in a moment sothat, as shown in FIG. 5C, a recess is formed along the stepped portion72. If the recess exceeds the tolerance, the product is not acceptable.Changing the cutting position is another method. The tool 74′(two-dotted line), however, possibly cuts too much under influence ofthe tool 73, then producing a streak. If it exceeds the tolerance, theproduct is not acceptable, either.

Instead of the NC program, electronic cam data may be used to solve theproblem. The tool 73 is started to machine the groove 75 while the tool74 (solid line) is moved from a position slightly apart from smallerdiameter part of the stepped portion 72 toward larger diameter partthereof. In other word, the tool 73 cuts the groove 75 during theretirement movement of the tool 74. There is then no streak left in theproduct. This operation also eliminates the risk of influence of thetool 73 upon the cutting depth of the tool 74.

1.2 Explanation of Step 2 in FIG. 5A

FIG. 6 is a subroutine of FIG. 5A showing search procedure for a portionof the simultaneous operation program to be transformed.

In Step 1, the current line B and the current channel CH are retrievedto determine a portion to be searched.

In Step 2, a timing command line T which comes first after the line B+1in the current channel CH is retrieved. (The timing command line Tcontains a timing code such as “timing=1”. The operations having thesame timing command are performed simultaneously.)

In Step 3, it is determined whether the timing command line T issuccessfully retrieved. If the line T is retrieved, the process goes toStep 4.

In Step 4, waiting lines A and B before and after the timing commandline T in the current channel are retrieved.

In Step 5, it is determined whether the block between the waiting linesA and B is part of the simultaneous operation. Step 5 preventsunnecessary transformation due to erroneous programming. If the block isnot part of the simultaneous operation, the process returns to Step 2.If the block is part of the simultaneous operation, the process goes toStep 6.

In Step 6, it is determined whether the block between the waiting linesA and B includes a command which is not transformable into electroniccam data. There are non-transformable commands such as a command forchanging rotational speed of the spindle and M codes such as a commandfor spraying lubricating oil. If Step 6 is “NO”, that is all data istransformable, the process goes to Step 7.

In Step 7, it is determined whether the current channel CH is undertransaction. If so, the process goes to Step 8.

In Step 8, corresponding waiting lines A and B before and after thetiming command line T in the non-current channels are retrieved.

In Step 9, it is determined whether the same timing code is notcontained in the block between the waiting lines A and B of thenon-current channel. If there exist one or more lines having the sametiming code, the block of the non-current channel are subject to Step 6.The process goes to Step 7, and then Step 10.

In Step 10, an existence flag is set ON meaning that there exists aportion to be transformed into electronic cam data. The lines A and Bare stored.

In Step 11, it is determined whether the stored lines A and B are thefinal set of lines. If they are the finals, the process goes to Step 12.

In Step 12, the existence flag ON, the current channel CH, and the allthe lines A and B stored in Step 10 are stored. The stored data isfinally passed to the transformation process for simultaneous operation.

On the other hand, if Step 6 is YES, that is, there exists acon-transformable command between the lines A and B, the process goes toStep 13.

In Step 13, it is determined whether the current channel CH is undertransaction. If the current channel CH is under transaction, the blockincluding the timing command line T between the lines A and B are notsubject to transformation. The process returns to Step 2 to searchanother transformable block.

If the current channel CH is not under transaction, that is a pluralityof A and B lines are found, the process goes to Step 14.

In Step 14, it is determined whether the subject block of A and B linesis the final block. This step assures that all the searched A and Bblocks are subject to Steps 6, 7, 10, and 11. If it is not the final,the process returns to Step 6. If it is the final, the process goes toStep 15.

In Step 15, it is determined whether the existence flag is set ON. If itis not ON, the process returns to Step 2. If it is ON, the process goesto Step 16.

In Step 16, the existence flag ON, the current channel CH, and the allthe lines A and B stored in Step 10 are stored. The stored data isfinally passed to the next processing.

On the other hand, if Step 3 is NO, that is, the timing command line Tis not successfully retrieved, the process goes to Step 17.

In Step 17, it is determined whether there exists a next channel. Ifthere exists a next channel, the process goes to Step 18.

In Step 18, the next channel is set as the current channel CH, and theStep 2 and subsequent steps are executed.

If there does not exist a next channel, the search processing ends.

Preferably, in Step 6, it may be determined whether there exist two ormore timing codes between the lines A and B before the search for anon-transformable command. If any, one of the timing codes should beremoved to prevent a subsequent processing confusion.

Preferably, it may be determined whether an axial movement command withrespect to one of three axes exists. It would prevent an improperprocessing in relevant occasions.

The timing code such as “timing=1” is solely described in a timingcommand line T. It is never described together with another command suchas M code or G code. The timing code is described to cause asimultaneous operation with respect to a plurality of channels. Portionsincluding the same timing code are simultaneously operated.

1.3 Explanation of Step 5 in FIG. 5A

FIG. 7 is a subroutine of FIG. 5A showing transformation of asimultaneous operation program into electronic cam data.

In Step 1, the block between A and B lines retrieved in Step 4 of FIG. 5is examined to determine whether a movement command exists with respectto any of control axis.

In Step 2, a current coordinate position before the movement command isretrieved with respect to the particular control axis.

In Step 3, the block between the A and B lines are examined in order andan element arrangement is made. The moving track and the moving speed ofthe workpiece or the tool is thus obtained. In making the elementarrangement, for the tool movement command in the NC program, thecutting edge position is corrected by modifying the tool coordinate.Making such offset adjustment simultaneously would shorten thetransformation time.

In Step 4, acceleration or deceleration is optimized. The position orthe point relative to the spindle rotational angle is determined tooptimize acceleration or deceleration of the workpiece or the tool.

In Step 5, a timing adjustment is executed to synchronize the channels.

In Step 6, the element arrangement is transformed into electronic camdata. As described above, an electronic cam data table is prepared andan identification number is attached thereto.

In Step 7, the NC program is modified. Particularly, the program betweenthe lines A and B is removed and instead a cycle command is insertedimmediately after the line A. The cycle command refers to data writtenin the electronic cam data table by the identification number attachedto the electronic cam data table.

2.1 Explanation of Step D in FIG. 4.

FIG. 8 is a subroutine of FIG. 4 showing transformation of anon-simultaneous operation program into electronic cam data.

In Step 1, the line number and the channel are initialized (A=0, B=0,CH=1).

In Step 2, a non-simultaneous operation program is searched for aportion to be transformed into electronic cam data.

In Step 3, it is determined whether there exists a portion to betransformed to an electronic cam data. If there exists, the process goesto Step 4, In Step 4, lines A and B which have been labeled (describedlater) are retrieved.

In Step 5, for the program between the lines A and B, the portion of thenon-simultaneous operation program is transformed into electronic camdata. When transformation is completed, the process returns to Step 2with the line B as a return value.

On the other hand, if there exists no portion to be transformed in Step3, the process goes to Step 6.

In Step 6, the channel CH is incremented for a next channel.

In Step 7, it is determined whether the current channel is CH=4. If yes,that is the NC programs for all the channels are completed, the processis completed and goes back to the main routine in FIG. 4. If the currentchannel is not yet CH=4, the process goes to Step 8.

In Step 8, the line number B is set to zero (0) and the NC program ofthe next channel CH is repeated from Step 2.

2.2 Explanation of Step 2 in FIG. 8

FIG. 9 is a subroutine of FIG. 8 showing search procedure for a portionof the non-simultaneous operation program to be transformed.

In Step 1, the current line B is retrieved.

In Step 2, the transformation start line A which comes first after theline B+1 is retrieved. The transformation start line has a labelattached thereto. The label in the form of a code is attached by a NCprogrammer to designate the portion to be transformed into electroniccam data. Examples include “DRILLING START” and “DRILLING END”. Thetransformation start line A is found by such label.

In Step 3, it is determined whether the transformation start line A issuccessfully retrieved. If there exists no start line A, the processgoes to Step 7.

In Step 7, it is determined that there does “not exist” a portion to betransformed into electronic cam data in the non-simultaneous operationprogram. The sub-routine ends and the process returns to the Step 3 ofFIG. 8.

On the other hand, if there exists the start line in Step 3, the processgoes to Step 4.

In Step 4, the transformation end line B which comes first after theline A+1 is retrieved. As described above, the transformation end line Bhas a label attached thereto, too.

In Step 5, it is determined whether the block between the line A and theline B contains a non-transformable program. If there exists nonon-transformable program, the process goes to Step 6.

In Step 6, it is determined that there “exists” a portion to betransformed into electronic cam data in the non-simultaneous operationprogram. The sub-routine ends and the process returns to the Step 3 ofFIG. 8.

On the other hand, if there exists a non-transformable program, theprocess goes to Step 8.

In Step 8, an error flag is set ON to output a log file, and the processreturns to Step 2 with the line B as a return value.

The label is, as described above, a comment attached to a program lineor a command to designate the program to be transformed into electroniccam data. It is described at the start and the end of the program suchas “DRILLING START” and “DRILLING END”. Such label may be automaticallyadded by a programming tool or may be manually inputted.

2.3 Explanation of Step 5 in FIG. 8

FIG. 10 is a subroutine of FIG. 8 showing transformation procedure ofnon-simultaneous operation program into electronic cam data.

In Step 1, the transformation start line A, the transformation end lineB, and the operation designated in the program between the line A andthe line B are retrieved.

In Step 2, it is determined whether the designated operation isthreading. If threading is designated, the process goes to Step 3.

In Step 3, threading operation is set and the process goes to Step 6.

If threading is not designated, the process goes to Step 4.

In Step 4, it is determined whether the designated operation is tapping.If tapping is designated, the process goes to Step 5.

In Step 5, tapping operation is set, and the process goes to Step 6. Iftapping is not designated in Step 4, the process goes to Step 8.

In Step 8, another kind of operation is set, and the process goes toStep 6.

In Step 6, the current coordinate is retrieved before the programbetween the line A and the line B is transformed into electronic camdata. This is because the NC program between the line A and the line Bdoes likely have no current coordinate, so lines before the line A mustbe searched.

In Step 7, transformation with respect to the respective control axes isexecuted, the NC program described between the line A and the line B ischanged to a cycle command, and the sub-routine is completed.

3.1 Explanation of Step E in FIG. 4

FIG. 11A is a subroutine of FIG. 4 showing optimization procedure of atool selection command position.

In Step 1, line numbers A, B, and C and tool selection command line Tare initialized (A=0, B=0, C=0, T=0). In this embodiment, Channels 1 and3 of which tools are opposite to each other are used. In this type ofnumerically controlled machine tool, the Step E technique is mostadvantageous in such opposite channels. Of course, Channel 2 may beincluded.

In Step 2, from the NC program for Channel 1 and 3, waiting lines A, B,and C and a tool selection command line T are retrieved.

In Step 3, it is determined whether they are successfully retrieved. Ifthey are not retrieved, the process returns to the main routine of FIG.4.

If they are retrieved, the process goes to Step 4.

In Step 4, the lines A, B, and C and the tool selection command line Tare stored.

In Step 5, the tool selection command position is optimized. Though thecommand is detected by the transformation program in this embodiment, itmay be designated by the NC programmer in programming. In any case, themachining time of the designated operation can be shortened.

A more concrete example is described below for further explanation.

As shown in FIG. 11B, a NC code designating an operation in Channel 1and Channel 3 wait at the lines {circle around (1)}, {circle around(2)}, and {circle around (3)}. (The above described waiting line Acorresponds to {circle around (1)}, line B to {circle around (2)}, andline C to {circle around (3)} respectively.)

In this example, for Channel 1, the machining time between the line{circle around (1)} and the line {circle around (2)} requires 10seconds. The machining time between the line {circle around (2)} and theline {circle around (3)} requires 8 seconds. For Channel 3, themachining time between the line {circle around (1)} and the line {circlearound (2)} requires 15 seconds. The machining time between the line{circle around (2)} and the line {circle around (3)} requires 5 seconds.

There is a tool selection command line T1 between the line {circlearound (2)} and the line {circle around (3)} in Channel 1. Required timefor selecting a tool is 2 seconds. FIG. 11C shows that Channel 1 waitsfor 5 seconds until Channel 3 completes the operation between the line{circle around (1)} and the line {circle around (2)}, and Channel 3waits for 3 seconds until Channel 1 completes the operation between theline {circle around (2)} and the line {circle around (3)}. Therefore,the total time from the line {circle around (1)} and the line {circlearound (3)} includes a waiting time of 8 seconds.

If tool selection is executed between the line {circle around (1)} andthe line {circle around (2)}, the waiting time is reduced by 2 secondssince a tool selection requires only 2 seconds. As shown in FIG. 11C,the total time (23 seconds) is reduced by 2 seconds (into 21 seconds) bythe shift of the T1 command position.

Similarly, it is assumed that there is a tool selection command line T3in Channel 3 (while there is no such command in Channel 1). Requiredtool selection time is 1 second. The T3 command is shifted to the blockbetween the line {circle around (1)} and the line {circle around (2)}.As shown in FIG. 11C, the total time (23 seconds) is increased by 1second (into 24 seconds) by the shift of the T3 command position.

Further, it is assumed that there are tool selection command line T1 andT3 in Channels 1 and 3, and they are shifted respectively. As shown inFIG. 11C, the total time (23 seconds) is reduced by 1 second (into 22seconds) by the shift of the T1 and T3 command positions.

As described above, waiting time may be decreased or increased byshifting the tool selection command. Therefore, a tool selection commandneeds be properly shifted to optimize (shorten) the machining time inview of time effect in every case.

3.2 Explanation of Step 2 in FIG. 11A

FIG. 12 is a subroutine of FIG. 11A showing retrieval procedure of linesA, B, and C, and tool selection command line T for Channels 1 and 3.

In Step 1, the lines A, B, and C and the tool selection command line Tare read.

In Step 2, the program following the line B in Channel 1 is examined andthe waiting lines A, B, and C which come first are retrieved.Corresponding lines in Channel 3 are also retrieved. Though all thelines A, B, and C are retrieved for the first time, only the line C isretrieved for the second time and thereafter since A=B and B=C areapplied.

In Step 3, it is determined whether the waiting lines A, B, and C aresuccessfully retrieved. If they are not retrieved, the process returnsto the main routine in FIG. 4. If they are retrieved, the process goesto Step 4.

In Step 4, it is determined whether the waiting code is effective. If itis effective, the process goes Step 5. The “effective waiting code”means that the waiting code is not associated with another channel. Incase the waiting code is not effective, that is, it is associated withanother channel, shifting the tool selection command line is preventedin Step 4. Particularly, when Channel 1 is supposed to use a tool on theside of Channel 3, the both channels are paused and then the tool ofChannel 3 is moved as instructed by the NC program.

In Step 5, a tool selection command line T of the smallest line numberbetween the line B and the line C in Channel 1 and Channel 3 isretrieved.

In Step 6, it is determined whether a tool selection command line T isnot successfully retrieved in either of Channel 1 and Channel 3. If itis successfully retrieved, the process goes to Step 7.

In Step 7, it is determined whether the line T is a sole command ineither of Channel 1 and Channel 3. The sole command means that the lineT does not include any other command than the tool selection commandsuch as a supplementary command like a spindle rotation change command.If a different command is included, the calculation of waiting time maybe wrong since such time is not provided from the timekeeping module.

In Step 7, if the tool selection command is the sole command, theprocess goes to Step 8.

In Step 8, it is determined whether an axial movement command existsbetween the line B and the tool selection command line T in either ofChannel 1 and Channel 3. An axial movement command is for the currenttool if it is before the tool selection command line T, not for the tooldesignated by the tool selection command line T. Therefore, if the toolselection command position is shifted beyond the axial movement command,the result would lose the purpose of the original NC program. Step 8 isprovided to prevent such problem.

If an axial movement command does not exist in Step 8, the sub-routineends and the process returns to the main routine of FIG. 11.

If Step 4 is NO, Step 6 is YES, Step 7 is NO, or Step 8 is YES, theprocess goes to Step 9.

In Step 9, the line B is replaced by A and the line C is replaced by B,and Step 2 and subsequent steps are repeated.

3.3 Explanation of Step 5 in FIG. 11A

FIG. 13 is a subroutine of FIG. 11A showing optimization procedure of atool selection command position in Channel 1 and Channel 3.

In Step 1, the line A, B, C, and the tool selection command line Tretrieved in FIG. 12 are read.

In Step 2, time data of the following parameters are retrieved from thetimekeeping module.

Channel 1

Operation Time from Line A to Line B: Time AB1

Operation Time from Line B to Line C: Time BC1

Tool Selection Time: Time T1(*)

Channel 3

Operation Time from Line A to Line B: Time AB3

Operation Time from Line B to Line C: Time BC3

Tool Selection Time: Time T3 (*)

(*) If there exist no tool selection command line, TimeT1 and TimeT3 arezero (0) respectively.

In Step 3, Opti1 (Optimization when only the tool selection command ofChannel 1 is shifted) is calculated by the following formula.Opti 1=(|TimeAB 1−TimeAB 3|−|(TimeAB 1+TimeT 1)−TimeAB 3|)+(|TimeBC1−TimeBC 3|−|(TimeBC 1−TimeT 1)−TimeBC 3|)

In Step 4, Opti3 (Optimization when only the tool selection command ofChannel 3 is shifted) is calculated by the following formula.Opti 3=(|TimeAB 1−TimeAB 3|−|TimeAB 1−(TimeAB 3+TimeT 3|)+(|TimeBC1−TimeBC 3|−|TimeBC 1−(TimeBC 3−TimeT 3|)

In Step 5, Opti13 (Optimization when the tool selection commands ofChannel 1 and Channel 3 are shifted) is calculated by the followingformula.Opti 13=(|TimeAB 1−TimeAB 31−|(TimeAB 1+TimeT 1)−(TimeAB 3+TimeT3|)+(|TimeBC 1−TimeBC 3|−|(TimeBC 1−TimeT 1)−(TimeBC 3−TimeT 3)|)

In Step 6, it is determined whether Opti1 is equal to or larger thanOpti3. If YES, the process goes to Step 7.

In Step 7, it is determined whether Opti1 is equal to or larger thanOpti13. If YES, the process goes to Step 8.

In Step 8, it is determined whether Opti1 is larger than zero (0). IfYES, the process goes to Step 9.

In Step 9, the tool selection command line T of Channel 1 is shiftedimmediately before the line B. This assures the axial movement commandto still act as originally intended.

On the other hand, if Opti 13 is larger than Opti1 in Step 7, theprocess goes to Step 11.

In Step 11, it is determined whether Opti13 is larger than zero (0). IfNO, the process returns to the main routine of FIG. 11A without shiftingthe tool selection command line. If YES, that is Opti 13 is larger thanzero (0), the process goes to Step 12.

In Step 12, the tool selection command line T of Channel 1 and Channel 3are shifted immediately before the line B.

On the other hand, if Opti1 is not larger than zero (0) in Step 8, theprocess returns to the main routine of FIG. 11A without shifting thetool selection command line T.

If Opti3 is larger than Opti1 in Step 6, the process goes to Step 10.

In Step 10, it is determined whether Opti3 is equal to or larger thanOpti13. If NO, that is, Opti13 is larger than Opti3, the process goes toStep 11. If YES, that is, Opti3 is larger than Opti13, the process goesto Step 13.

In Step 13, it is determined whether Opti3 is larger than zero (0). Ifit is a negative value, the process returns to the main routine of FIG.11A without shifting the tool selection command line T. If it is apositive value, the process goes to Step 14.

In Step 14, the tool selection command line T of Channel 3 is shiftedimmediately before the line B.

4.1 Explanation of Step F in FIG. 4

FIG. 14 is a subroutine of FIG. 4 showing transformation of a toolselection operation program into electronic cam data.

In Step 1, initialization is done (B=0, CH=1).

In Step 2, the tool selection command line T and the waiting lines A andB before and after the line T are retrieved.

In Step 3, it is determined whether the tool selection command line Tand the waiting lines A and B exist. If they exist, the process goes toStep 4.

In Step 4, the lines A, B and T are read.

In Step 5, the tool selection operation is transformed into electroniccam data. Step 2 and subsequent steps are repeated for the line B andsubsequent lines.

On the other hand, if the tool selection command line T and the waitinglines A and B do not exist in Step 3, the process goes to Step 6.

In Step 6, the channel CH is updated. Since the NC program of thecurrent channel does not include a tool selection command line T atleast in the program following the line B, the channel CH is changed toa next channel.

In Step 7, it is determined whether the current channel is CH=4. If NO,the process goes to Step 8.

In Step 8, the lines A and B, and the tool selection command line T areinitialized, and the Step 2 and subsequent steps are repeated.

On the other hand, if the current channel is CH=4, the process returnsto the main routine of FIG. 1 since all the channels are fully searched.

4.2 Explanation of Step 2 in FIG. 14

FIG. 15 is a subroutine of FIG. 14 showing retrieval procedure of toolselection command line T and waiting lines A and B to be transformedinto electronic cam data.

In Step 1, the line B is read.

In Step 2, a tool selection command line T which comes first after theline B+1 is retrieved.

In Step 3, it is determined whether the tool selection command line T issuccessfully retrieved. If it is not retrieved, the process goes to theroutine of FIG. 14. If it is retrieved, the process goes to Step 4.

In Step 4, waiting lines A and B before and after the tool selectioncommand line T are retrieved.

In Step 5, it is determined whether the waiting codes are effective. Ifthey are not effective, the Step 2 and subsequent steps are repeated. Ifa waiting code of a channel is associated with another channel as in anX1–X3 synchronization, the transformation would lose the intendedassociation of the channels. Therefore, the Step 5 is provided toeliminate such ineffective waiting code.

If a waiting code is effective, the process goes to Step 6.

In Step 6, it is determined whether the waiting time is longer than thatof any of other channels. If YES, that is, the waiting time is thelongest, the process returns to Step 2. If NO, the process goes to Step7. This determination is performed to confirm that extra time actuallyallowed for tool selection by the tool selection command line T in thechannel is enough in view of tool selection of the annother channel.

In Step 7, the tool selection command line T, the waiting start line A,and the waiting end line B are stored.

In Step 8, it is determined whether Channel 3 is the current channel. IfYES, the process goes to Step 9.

In Step 9, it is determined whether the tool selection command ofChannel 1 has been transformed into electronic cam data. If YES, theprocess goes to Step 10.

In Step 10, the memory of the tool selection command line T, the waitingstart line A, and the waiting end line B (stored in Step 7) iscancelled. The process returns to the main routine of FIG. 14 with theresult that the tool selection command line T and the waiting lines Aand B do “not exist”.

Simultaneous tool selection on Channel 1 and Channel 3 is rare. If onechannel has been transformed into electronic cam data, the other channelshould not be transformed since transformation on both channels wouldpossibly cause a trouble on operation.

If the tool selection command of Channel 1 is not transformed in Step 9,the process returns to the main routine of FIG. 14 with the result thatthe tool selection command line T and the waiting lines A and B “exist”.

If it is determined that Channel 3 is not the current channel in Step 8,the process returns to the main routine of FIG. 14 with the result thatthe tool selection command line T and the waiting lines A and B “exist”since the lines A, B, and T have been retrieved at least in Channel 1.

4.3 Step 5 in FIG. 14

FIG. 16 is a subroutine of FIG. 14 showing transformation of a toolselection program into electronic cam data.

In Step 1, the tool selection command line T, the waiting start line A,and the waiting end line B are read.

In Step 2, the time difference ΔT is calculated compared with thelongest waiting time of another channel.

In Step 3, the tool selection command line between the waiting lines Aand B and the tool selecting time are all read out from the NC programand the timekeeping module respectively.

In Step 4, the difference ΔT is divided in proportion to the duration ofeach tool selecting time.

In Step 5, the tool selection operation is transformed into electroniccam data in which the tool selection operation is more slowly performedin accordance with the divided time.

In Step 6, the line B is stored and the process returns to the mainroutine.

As described above, the calculated extra time for every tool selectioncommand is allocated in proportion to the duration of each toolselecting time as an additional tool selecting time. Ordinarily, thetool selective operation by the NC program would be done quickly withextra time left in whole even if such time is allocated. The toolselection of the present invention is, however, done using the wholetime including the allocation. Therefore, the tool selection of thepresent invention is slowly executed than the NC program, with theresult that the tool post shaft or the bearings for supporting therotational members are subject to less shock or load, thus elongatingthe life of the parts and improving the accuracy of the product.

Preferably in Step 5, the moving speed of the tool may be varieddepending on the operation. For example, the tool moves fast whenretracted in machining completion while the tool moves slowly whenadvanced to the selected position. This prevents the retracting toolfrom interfering with the spindle to the same degree as controlled bythe NC program.

In this embodiment, the program file stored in the NC device of thenumerically controlled machine tool are processed and then stored in theRAM for the NC device. Instead, the processing may be executed just whenthe program file is read out from the RAM for the NC device by the CPU.In this case, the NC program may be read out in advance and processed asdescribed above to operate the numerically controlled machine.

According to the present invention, the operation of the workpiece andthe tool is optimized as if the programming is made by a skilled NCprogrammer. The invention further has an effect on operating time,product cost, product quality, and machine life.

1. A numerically controlled machine tool, comprising: a NC program to be loaded into the numerically controlled machine tool, wherein the NC program comprises a plurality of channels; memory means for storing the NC program whose portion to be determined whether a tool selection command position is changeable is designated; determining means for determining whether an operating time by a selected tool is shortened by changing the tool selection command position in waiting conducted in the plurality of channels; command position changing means for changing the tool selection command position of the portion designated in the NC program when the determining means determines that the operating time is shortened by changing the tool selection command position; and a numerical control unit for operating the machine tool according to the NC program changed by the command position changing means.
 2. The numerically controlled machine tool as claimed in claim 1, further comprising: an offset data storage portion for storing positional offset data of a workpiece or a tool; and transforming means for transforming the NC program into electronic cam data, the transforming means applying the offset data to the electronic cam data when transforming the NC program into the electronic cam data.
 3. A method for optimizing a NC program for operating a numerically controlled machine tool, comprising: making the NC program to be loaded into the numerically controlled machine tool, wherein the NC program comprises a plurality of channels; designating a portion of the NC program to be determined whether a tool selection command position is changeable; storing the NC program in a predetermined memory in the numerically controlled machine tool; in waiting conducted in the plurality of channels, determining whether an operating time by a selected tool is shortened by changing the tool selection command position; changing the tool selection command position when it is determined that the operating time is shortened by changing the tool selection command position; and making an operating program file for the numerically controlled machine tool. 